Ext.define('ES.view.components.RatingComp',{
	extend:'Ext.container.Container',
	alias:'widget.ratingcomp',
	requires:['Ext.container.Container'],
	config:{
		rating:0
	},
	layout:{
		type:'hbox',
		defaultMargins:{top: 0, right: 2, bottom: 0, left: 0}
	},
	setRating:function(rating){
		this.removeAll();
		var ratingBoxes = new Array();
		for(var i = 0 ; i < rating; i++)
		{
			var ratingImg = Ext.create('Ext.Img',{
				src:'app/assets/star.png',
				width:16,
				height:16
			});
			ratingBoxes.push(ratingImg);
		}
		for(var j = 0; j < 5 - rating; j++)
		{
			var ratingImg = Ext.create('Ext.Img',{
				src:'app/assets/star_off.png',
				width:16,
				height:16
			});
			ratingBoxes.push(ratingImg);
		}
		this.add(ratingBoxes);
	},
	onRender:function(){
		this.setRating(this.rating);
		this.superclass.onRender.call(this);
	}
});
